package vendalenger.debvi.jfx;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;

@Deprecated
public class VD_QuickButton extends JButton {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5287784849280747126L;
	public Icon ico;

	@Deprecated
	public VD_QuickButton(JComponent bind, int layout, Dimension size, String text,
			String tooltip, String path) {
		super();
		if (new File(path).exists()) {
			try {
				BufferedImage icon = ImageIO.read(new File(path));
				if (!size.equals(new Dimension(0, 0))) {
					BufferedImage b2 = new BufferedImage(size.width,
							size.height, BufferedImage.TYPE_4BYTE_ABGR);
					Graphics g = b2.getGraphics();
					g.drawImage(icon, 0, 0, size.width, size.height, null);
					g.dispose();
					icon = b2;
					this.setSize(size);
				}
				setIcon(new ImageIcon(icon));
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		setText(text);
		setToolTipText(tooltip);
		addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				function(e);
			}
		});
		if (bind != null) {
			bind.add(this, layout);
		}
	}

	@Deprecated
	public void function(ActionEvent e) {
	}
}
